package com.yonyou.cloud.member.adapters.openapi.controller;

import com.yonyou.cloud.member.adapters.dto.ApiResponseDto;
import com.yonyou.cloud.member.domainmodel.context.ServiceContext;
import com.yonyou.cloud.member.domainmodel.dto.MemberPointHistoryDto;
import com.yonyou.cloud.member.domainmodel.dto.MemberPointQueryConditionDto;
import com.yonyou.cloud.member.domainmodel.dto.PageQueryResult;
import com.yonyou.cloud.member.domainmodel.vo.MemberId;
import com.yonyou.cloud.member.domainmodel.services.MemberService;
import com.yonyou.cloud.member.domainmodel.vo.TimeRange;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@Api(tags = "会员积分")
@RestController
@RequestMapping("/member/points")
public class MemberPointController {
    @Autowired
    MemberService memberService;

    @PostMapping("/v1/history/query")
    @ApiOperation(value = "会员积分变更明细查询", httpMethod = "POST")
    public ApiResponseDto<PageQueryResult<MemberPointHistoryDto>> inbound(@RequestBody MemberPointQueryConditionDto conditionDto, HttpServletRequest request) {
        ServiceContext serviceContext = createServiceContext(request);
        MemberId memberId = conditionDto.getMemberId();
        TimeRange timeRange = conditionDto.getTimeRange();
        PageQueryResult<MemberPointHistoryDto> result = memberService.queryMemberPointHistory(conditionDto, serviceContext);
        return new ApiResponseDto(true).setData(result);
    }

    private ServiceContext createServiceContext(HttpServletRequest request) {
        return null;
    }
}
